#ifndef USRAI_H
#define USRAI_H

#include "AI.h"

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}

    // set functions
    void BuildMap ();
    void TestMap ();
    void Init_SpaceMap();
    void ResourceMap();
    void Traverse_resources();
    void Traverse_buildings();
    pair<int, int> find_Center();
    double cal_dis(double x1, double y1, double x2, double y2);
    void farmers_to_work(tagFarmer &e, int job);
    void Building_produce(int op);
    void farmers_building(int op, tagFarmer &e, int x, int y);
    int cal_buildings(int op);
    bool find_empty_area(int x, int y);
    pair<int, int> bfs(int x, int y);
    int cal_farmers();
    void init_resources_buildings();
    void find_farmers();
    pair<int, int> find_water(int x, int y);
    void find_fish();
    void init_building_numbers();
    int cal_ships(int op);
    pair<int, int> find_Home();
    int cal_army(int op);
    void attack(int op);
    void init_explore_ocean();
    pair<int, int> get_next_explore_poi(int start_x, int start_y);
    void order_ship_explore();
    void detect_enemyland();
    int cal_enemy(int op);
    pair<int, int> find_near_water(int x, int y);
    void shipExploreAndCombat();

private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/
    bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);

};

/*##########YOUR CODE BEGINS HERE##########*/

    
/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
